package com.serenegiant.usbcameratest4.util;

import android.annotation.SuppressLint;
import android.hardware.usb.UsbDevice;

public class USBDeviceUtils {

    private static USBDeviceUtils inst;
    private USBDeviceUtils(){}

    public static synchronized USBDeviceUtils getInstance(){
        if(inst ==null){
            inst =new USBDeviceUtils();
        }
        return inst;
    }

    public boolean isUVC(final UsbDevice device )
    {
        if( device.getDeviceClass() == 239 && device.getDeviceSubclass() == 2 ) {
            return true;
        }
        return false;
    }

    @SuppressLint("NewApi")
    public boolean isUVCCamera(final UsbDevice device )
    {
        if( device.getProductName() != null ) {
            //device.getDeviceClass() == 239 && device.getDeviceSubclass() == 2 &&
//            if ( device.getProductName().contains("Camera")) {
//                return true;
//            }
            //Product
            if( device.getDeviceClass() == 239 && device.getDeviceSubclass() == 2 && device.getProductId() == 12341 && device.getVendorId() == 3034 ) {
                return true;
            }
            //C920
            if( device.getDeviceClass() == 239 && device.getDeviceSubclass() == 2 && device.getProductId() == 2093 && device.getVendorId() == 1133 ) {
                return true;
            }
        }
        return false;
    }

    @SuppressLint("NewApi")
    public boolean isT3HCamera(final UsbDevice device )
    {
        if( device.getProductName() != null ) {
            if (device.getProductName().contains("T3") || device.getProductName().contains("Xtherm") || device.getProductName().contains("Xmodule")) {
                return true;
            }
        }
        return false;
    }

}
